package com.bqtv.sport.dialog

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import com.bqtv.sport.databinding.DialogSelectPicBinding
import com.hjq.base.BaseDialog
import com.hjq.base.BottomSheetDialog

class SelectPicBottomDialog {
    class Builder(context: Context) : BaseDialog.Builder<Builder>(context) {
        var binding: DialogSelectPicBinding =
            DialogSelectPicBinding.inflate(
                LayoutInflater.from(context),
                FrameLayout(context),
                false
            )

        init {
            setContentView(binding.root)
            setData()
        }

        fun setData(): Builder {


            setOnClickListener(binding.tvTakePhoto, binding.tvAlbum, binding.tvCancel)
            return this
        }

        override fun onClick(view: View) {
            super.onClick(view)
            if (view == binding.tvTakePhoto) {
                clickResult?.onPhotoClick()
                dismiss()
            } else if (view == binding.tvAlbum) {
                clickResult?.onAlbumClick()
                dismiss()
            } else if (view == binding.tvCancel) {
                dismiss()
            }
        }

        override fun createDialog(context: Context, themeId: Int): BaseDialog {
            val dialog = BottomSheetDialog(context, themeId)
            dialog.getBottomSheetBehavior().setSkipCollapsed(true)
            return dialog
        }

        var clickResult: ClickResult? = null

        interface ClickResult {
            fun onPhotoClick()
            fun onAlbumClick()
        }
    }
}